package ar.uade.distribuidas.tpo.dba.dao;

import java.util.LinkedList;
import java.util.List;

import org.hibernate.Session;


import ar.uade.distribuidas.tpo.dba.dominio.Cliente;
import ar.uade.distribuidas.tpo.dba.hbt.HibernateDAO;

public class ClienteDAO extends HibernateDAO {

	private static ClienteDAO instance;

	public ClienteDAO() {
		super();
	}

	public static ClienteDAO getInstance() {
		if (instance == null) {
			instance = new ClienteDAO();
		}
		return instance;
	}
	
	public Cliente getCliente(long cuil) {
		
		Cliente r = (Cliente) this.getSession().createQuery("from Cliente where cuil = :cuil")
				.setParameter("cuil", cuil)				
				.uniqueResult();		
		
		return r;
	}
	
	
	@SuppressWarnings("unchecked")
	public List<Cliente> getAllClientes(){
		List<Cliente> res = new LinkedList<Cliente>();
	           
		res =  this.getSession().createQuery("from Cliente").list();
	   
		
		return res;
	}

}
